{% extends 'rbac/base.html' %}
{% block addcss %}
    <link href="/static/css/plugins/sweetalert/sweetalert.css" rel="stylesheet">
    <style>
        .font-size-16 {
            font-size: 16px;
        }

        .border_color {
            border-left: solid #ff911e 4px;
            background-color: #ECECEC;

        }

        .i-default {
            font-size: 15px;
            display: inline-block;
            color: #676a6c;
        }

        .add-btn-a {
            padding: 2px 8px;
            margin: -3px;
            color: #fff !important;
        }
    </style>
{% endblock %}
{% block content %}
    {% load menu %}
    {% breadcrumb request %}
    <div class="wrapper wrapper-content animated fadeIn">
        <div class="row">
            <div class="col-lg-12">
                <form method="post" action="?type=generate">
                    {% csrf_token %}
                    {{ generate_formset.management_form }}
                    <div class="ibox">
                        <div class="ibox-title">
                            <h5><i class="fa fa-cubes "></i>&nbsp;&nbsp;待新增权限</h5>

                            <div class="ibox-tools">
                                <button class="right btn btn-primary btn-xs">
                                    <i class="fa fa-plus-circle" aria-hidden="true"></i> 新建
                                </button>
                            </div>
                        </div>
                        <div class="ibox-content" style="">
                            <table class="table table-hover">
                                <thead>
                                <tr>
                                    <th>序号</th>
                                    <th>名称</th>
                                    <th>URL</th>
                                    <th>别名</th>
                                    <th>菜单</th>
                                    <th>父权限</th>
                                </tr>
                                </thead>
                                <tbody>
                                {% for form in generate_formset %}
                                    <tr>
                                        <td>{{ forloop.counter }}</td>
                                        {% for field in  form %}
                                            <td>
                                                {{ field }}
                                                <span class="form-text m-b-none text-danger">{{ field.errors.0 }}</span>
                                            </td>
                                        {% endfor %}
                                    </tr>
                                {% endfor %}
                                </tbody>
                            </table>
                        </div>
                    </div>

                </form>

            </div>
        </div>

        <div class="row">
            <div class="col-lg-12">
                <div class="ibox">
                    <div class="ibox-title">
                        <h5><i class="fa fa-cubes "></i>&nbsp;&nbsp;待删除权限列表</h5>
                    </div>
                    <div class="ibox-content">
                        <table class="table table-hover">
                            <thead>
                            <tr>
                                <th>序号</th>
                                <th>名称</th>
                                <th>URL</th>
                                <th>别名</th>
                                <th>删除</th>
                            </tr>
                            </thead>
                            <tbody>
                            {% for row in delete_row_list %}
                                <tr>
                                    <td>{{ forloop.counter }}</td>
                                    <td>{{ row.title }}</td>
                                    <td>{{ row.url }}</td>
                                    <td>{{ row.name }}</td>
                                    <td>
                                        <a style="color: #d9534f;" id="{{ row.id }}" href="#"
                                           del-url="{% url 'rbac:multi_permissions_del' pk=row.id %}"
                                        class="a-del" >
                                            <i class="fa fa-trash-o a-del"></i>
                                        </a>
                                    </td>
                                </tr>
                            {% endfor %}
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>

        </div>

        <div class="row">
            <div class="col-lg-12">
                <form method="post" action="?type=update">
                    {% csrf_token %}
                    {{ update_formset.management_form }}
                    <div class="ibox">
                        <div class="ibox-title">
                            <h5><i class="fa fa-cubes "></i>&nbsp;&nbsp;待修改权限</h5>

                            <div class="ibox-tools">
                                <button class="right btn btn-primary btn-xs">
                                    <i class="fa fa-save" aria-hidden="true"></i> 保存
                                </button>
                            </div>
                        </div>
                        <div class="ibox-content" style="">
                            <table class="table table-hover">
                                <thead>
                                <tr>
                                    <th>序号</th>
                                    <th>名称</th>
                                    <th>URL</th>
                                    <th>别名</th>
                                    <th>菜单</th>
                                    <th>父权限</th>
                                </tr>
                                </thead>
                                <tbody>
                                {% for form in update_formset %}
                                    <tr>
                                        <td>{{ forloop.counter }}</td>
                                        {% for field in  form %}
                                            {% if forloop.first %}
                                                {{ field }}
                                            {% else %}
                                                <td>
                                                    {{ field }}
                                                    <span class="form-text m-b-none text-danger">{{ field.errors.0 }}</span>
                                                </td>
                                            {% endif %}
                                        {% endfor %}
                                    </tr>
                                {% endfor %}
                                </tbody>
                            </table>
                        </div>
                    </div>

                </form>

            </div>
        </div>
    </div>
{% endblock %}

{% block addjs %}
    <script src="/static/js/plugins/sweetalert/sweetalert.min.js"></script>
    <script src="/static/rbac/del.js"></script>
{% endblock %}